package com.niu.test;

import java.util.ArrayList;
import java.util.Arrays;

public class Number {
    public static void main(String[] args) {
//        ArrayList arrayList = new ArrayList();
//        for (int i = 0; i <= 200 ; i++) {
////            System.out.println("1");
//            if (i%7 ==0 && i%4 !=0){
//                System.out.println(i);
//            }
//
//        }
//        System.out.println(arrayList.toString());
        String word = "Let's have fun";
//        changeWord(word);
//        System.out.println(changeWord(word));
         int[] arr =new int[]{2, 8, 11, 15} ;
         int target = 9;
        findNum(arr,target);

    }

    public static String changeWord(String word) {
        String[] arr = word.split(" ");
        String word1 = "";
        for (int i = 0; i < arr.length; i++) {
            String temp = arr[i];
            String temp1 = "";
            char[] chars = temp.toCharArray();
            for (int j = chars.length - 1; j >= 0; j--) {
                temp1 = temp1 + chars[j];
                arr[i] = temp1;
            }
        }
        for (int i = 0; i < arr.length; i++) {
            word1 = word1 + arr[i] + " ";
        }
        return word1;
    }

    public static void findNum(int[] arr,int target){
        Arrays.sort(arr);
        int left = 0;
        int right = arr.length-1;
        while (left <right){
            if (arr[left] + arr[right] > target){
                    right--;
            }else if (arr[left] + arr[right] < target){
                left++;
            }else {
                System.out.println(arr[left] + "," +arr[right]);
                return;
            }
        }
        System.out.println("找不到这俩数");
    }
}
